package com.jixi.controller;

import com.jixi.common.result.Result;
import com.jixi.pojo.vo.TodayStatusVo;
import com.jixi.pojo.vo.TotalStatusVo;
import com.jixi.service.ClassesService;
import com.jixi.service.OrderDailyService;
import com.jixi.service.StudentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Tag(name = "今日数据看板接口")
@RestController
@RequestMapping("/teacher/data")
public class DataController {
    @Autowired
    private OrderDailyService orderDailyService;
    @Autowired
    private ClassesService classesService;
    @Autowired
    private StudentService studentService;
    /**
     * 今日数据看板信息
     *
     * @return 今日订餐总数，今日退餐总数
     * */
    @GetMapping("/todayStatus")
    @Operation(summary = "今日数据看板信息")
    public Result<TodayStatusVo> getTodayStatus(){
        //构造查询
        //1.查询今日订餐总数
        Long orderCount = orderDailyService.getByDateCount();
        //2,查询今日退餐总数
        Long returnCount = orderDailyService.getByReturnCount();
        //封装
        TodayStatusVo todayStatusVo = new TodayStatusVo(orderCount,returnCount);
        //返回
        return Result.success(todayStatusVo);
    }
    /**
     * 累计数据看板信息
     *
     * @return 累计订餐天数，累计订餐人数，管理班级个数，管理学生人数
     * */
    @GetMapping("/totalStatus")
    @Operation(summary = "累计数据看板信息")
    public Result<TotalStatusVo> getTotalStatus(){
        //构造查询
        //1.查询累计订餐天数
        Long orderDays = orderDailyService.getOrderDays();
        //2.查询累计订餐人数
        Long orderCounts = orderDailyService.getOrderCounts();
        //3.查询管理班级个数
        Long totalClasses = classesService.getTotalClasses();
        //4.查询管理学生人数
        Long totalStudents = studentService.getTotalStudents();
        //封装
        TotalStatusVo totalStatusVo = new TotalStatusVo(orderDays,orderCounts,totalClasses,totalStudents);
        //返回
        return Result.success(totalStatusVo);
    }
}
